knitr::opts_chunk$set(echo = TRUE)
list.of.packages <- c("gsheet", "tidyverse", "janitor", "plotly", "glmmTMB", "metafor", "broom.mixed", "car", "viridis") #add new libraries here
new.packages <- list.of.packages[!(list.of.packages %in% installed.packages()[,"Package"])]
if(length(new.packages)) install.packages(new.packages)
# Load all libraries
lapply(list.of.packages, FUN = function(X) {
do.call("require", list(X))
})
sessionInfo()
NOTE: data is read directly from the GoogleSheet using a share link that was set to “anyone with a link can view”
# Read in data from GoogleSheet
cases <- as_tibble(gsheet2tbl('https://docs.google.com/spreadsheets/d/1oKdlyh5LIbHGMThIzJ5uFQ8uYe7CDTRjWnsDcIbQRbo/edit?usp=sharing'))
cases
## # A tibble: 108 x 6
## Date Zip Cases Cases.per.100k Deaths Deaths.per.100k
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 4/20/2020 98106 78 301. 2 7.7
## 2 4/20/2020 98126 65 267 5 20.5
## 3 4/20/2020 98116 34 126 0 0
## 4 4/20/2020 98136 19 117. 1 6.2
## 5 4/20/2020 98146 79 270. 2 6.8
## 6 4/20/2020 98166 58 266. 3 13.7
## 7 4/20/2020 98168 119 330. 1 2.8
## 8 4/20/2020 98148 35 323. 1 9.2
## 9 4/20/2020 98108 61 242. 1 4
## 10 4/21/2020 98116 35 130. 0 0
## # … with 98 more rows
No. of cases over time by zip
ggplotly(ggplot(data=cases, aes(x=Date, y=Cases, group=factor(Zip), colour=factor(Zip))) + theme_minimal() +
geom_line(size=1.75) + scale_color_viridis(discrete = TRUE) + ggtitle("No. of cases"))
No. of cases per 100k over time by zip
ggplotly(ggplot(data=cases, aes(x=Date, y=Cases.per.100k, group=factor(Zip), colour=factor(Zip))) + theme_minimal() +
geom_line(size=1.75) + scale_color_viridis(discrete = TRUE) + ggtitle("Case rate per 100k"))
No. of deaths over time by zip
ggplotly(ggplot(data=cases, aes(x=Date, y=Deaths, group=factor(Zip), colour=factor(Zip))) + theme_minimal() +
geom_line(size=1.75) + scale_color_viridis(discrete = TRUE) + ggtitle("No. of deaths"))
No. of deaths per 100k over time by zip
ggplotly(ggplot(data=cases, aes(x=Date, y=Deaths.per.100k, group=factor(Zip), colour=factor(Zip))) + theme_minimal() +
geom_line(size=1.75) + scale_color_viridis(discrete = TRUE) + ggtitle("Death rate per 100k"))